<?php
namespace Model;
use Kuyuan\WqCore\Model\Model;
class MediaModel extends Model
{
    protected $_fields = array(
        "id",
        "uniacid",
        "uid",
        "type",
        "source",
        "thumb",
        "filename",
        "time",
        "size",
        "status"
    );

    /**
     * 封面
     * @param $_value
     * @return mixed
     */
    public function getThumbAttr($_value)
    {
        return tomedia($_value);
    }

    /**
     * 视频url
     * @param $_value
     * @param $_data
     * @return |null
     */
    public function getVideoUrlAttr($_value,$_data)
    {
        if($_data["type"] == "video"){
            return tomedia($_data["source"]);
        } else {
            return null;
        }
    }

    /**
     * 图片url
     * @param $_value
     * @param $_data
     * @return |null
     */
    public function getImageUrlAttr($_value,$_data)
    {
        if($_data["type"] == "image"){
            return tomedia($_data["source"]);
        } else {
            return null;
        }
    }
}